
let _confirm = {

    query: function (that, msg, title, callback = null, errorCallback = null) {
        that.$confirm(msg, title,{
            confirmButtonText: '确定',
            cancelButtonText:  '取消',
            cancelButtonClass: "btn-custom-cancel",
            confirmButtonClass: "btn-custom-confirm",
            type: 'warning',
            center: true,
        }).then((_) => {
            if (typeof callback === "function")
                callback()
        }).catch((_) => {
            if (typeof errorCallback === "function")
                errorCallback()
        });
    },

    del: function (that, js_class, id, page, callback = null, errorCallback = null) {
        that.$confirm('确定要删除此数据么？', {
            confirmButtonText: '确定',
            cancelButtonText:  '取消',
            cancelButtonClass: "btn-custom-cancel",
            confirmButtonClass: "btn-custom-confirm",
            type: 'warning',
        }).then((_) => {
            js_class.del(id, function (data) {
                callback = callback == null ? 'select_page' : callback
                if (that.hasOwnProperty(callback) && typeof that[callback] === "function")
                    that[callback](page)
            })
        }).catch((_) => {
            if (typeof errorCallback === "function")
                errorCallback()
        });
    }
};

export default _confirm
